<?php
//购买日志()
function recharge_log($store_id,$user_id,$balance,$type,$order_sn,$pay_type,$message,$state,$level_id){
	//购买日志
	$credit_data = array(
		'store_id'		=> $store_id,
		'user_id'		=> $user_id,
		'balance'		=> $balance,
		'origin_price'	=> $balance,
		'type' 			=> $type,
		'order_sn' 		=> $order_sn,
		'pay_type' 		=> $pay_type,
		'state' 		=> 1,
		"msg"		=> $message,
		"order_id"		=> 0,
		'add_time' 		=> now_time(),
		'state'			=>$state,
		'level_id'		=>$level_id
	);
	$res= db('paylog')->insert($credit_data);
	return $res;
}
//充值消费日志
function consume_log($order_sn,$user_id,$store_id,$balance,$fill_id,$pay_type,$level_id,$time,$type,$staff_id,$msg,$uh_id=0){
	//购买日志
	$credit_data = array(
		'order_sn'		=> $order_sn,
		'user_id'		=> $user_id,
		'store_id'		=> $store_id,
		'balance'	=> $balance,
		'fill_id' 			=> $fill_id,
		'pay_type' 		=> $pay_type,
		'level_id' 		=> $level_id,
		'time' 		=> $time,
		"type"		=> $type,
		"staff_id"		=> $staff_id,
		'msg' 		=> $msg,
		'uh_id'		=>$uh_id
	);
	$res= db('consume')->insert($credit_data);
	return $res;
}


/**
 * 预定日志
 * */
function reserve_log($user_id,$store_id,$room_id,$start_time,$end_time,$room_num,$ids_num,$dd_time,$order_id,$zf_type,$origin_price,$balance,$is_hx=0,$days){
	$data =array(
		'user_id'	=>$user_id,
		'store_id'	=>$store_id,
		'room_id'	=>$room_id,
		'start_time'=>$start_time,
		'end_time'	=>$end_time,
		'room_num'	=>$room_num,
		'ids_num'	=>$ids_num,
		'dd_time'	=>$dd_time,
		'order_id'	=>$order_id,
		'zf_type'	=>$zf_type,
		'balance'	=>$balance,
		'origin_price'=>$origin_price,
		'is_hx' 	=>$is_hx,
		'state'		=>1,
		'days'		=>$days,
		'add_time'	=>now_time()
	);
	$res = db('reserve')->insert($data);
	return $res;
}

//房间预定日志
function reserve_pay_log($store_id,$user_id,$balance,$type,$order_sn,$pay_type,$message,$state,$level_id,$origin_price,$room_id,$pay_time=""){
	$credit_data = array(
		'store_id'		=> $store_id,
		'user_id'		=> $user_id,
		'balance'		=> $balance,
		'origin_price'	=> $origin_price,
		'type' 			=> $type,
		'order_sn' 		=> $order_sn,
		'pay_type' 		=> $pay_type,
		'state' 		=> $state,
		"msg"		=> $message,
		'add_time' 		=> now_time(),
		'state'			=>$state,
		'level_id'		=>$level_id,
		'room_id'		=>$room_id,
		'pay_time'		=>$pay_time
	);
	$res= db('paylog')->insert($credit_data);
	return $res;
}

//分佣日志
function add_commission($ywy_id,$ywy_yj,$user_id,$level_id,$balance,$message,$type){
	$data = array(
		'ywy_id'		=> $ywy_id,
		'ywy_yj'		=> $ywy_yj,
		'user_id'		=> $user_id,
		'level_id'  	=> $level_id, 
		'balance' 		=> $balance, 
		'message' 		=> $message, 
		'type' 		    => $type, 
		'add_time' 		=> now_time()
	);
	$res= db('commission')->insert($data);
	return $res;
}

/**
 * 餐厅预定日志
 * */
function restaurant_log($user_id,$store_id,$room_num,$dd_time,$type,$msg,$jc_time,$is_rooms,$order_id,$state=0){
	$data =array(
		'user_id'	=>$user_id,
		'store_id'	=>$store_id,  
		'room_num'	=>$room_num, 
		'dd_time'	=>$dd_time, 
		'type'	=>$type,  
		'state'		=>$state,
		'msg'		=>$msg,
		'jc_time'		=>$jc_time,
		'is_rooms'		=>$is_rooms,
		'order_id'	=>$order_id,
		'add_time'	=>now_time()
	);
	$res = db('reserve_ct')->insert($data);
	return $res;
}


//变更房券，购买记录
function fq_log($type,$order,$user_id,$uh_id,$num,$time,$msg,$zs_zfq,$zs_type,$store_id,$balance,$level_id,$staff_id){
		$datas['type'] = $type;
		$datas['order_sn'] = $order;
		$datas['user_id'] = $user_id;  
		$datas['uh_id'] = $uh_id;
		$datas['num'] = $num;
		$datas['time'] = $time;
		$datas['msg'] = $msg;
		$datas['zs_zfq'] = $zs_zfq; 
		$datas['zs_type'] = $zs_type;
		$datas['store_id'] = $store_id;
		$datas['balance'] = $balance;
		$datas['level_id'] = $level_id;
		$datas['staff_id'] = $staff_id;
		$res = db('consume')->insert($datas);
		return $res;
}	